#!/bin/bash

# crontab  */2 * * * * /root/monitor.sh >> /tmp/monitor.log 2>&1

curl -s http://127.0.0.1:60010 > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
    echo "$(date '+%Y-%m-%d %H:%M:%S') [ERROR] service is down."
    systemctl stop cloudera-scm-service.service
    rm -rf /tmp/hsperfdata_*
    systemctl start cloudera-scm-service.service
    sleep 60
    systemctl start opentsdb
else
    echo "$(date '+%Y-%m-%d %H:%M:%S') [INFO] ok."
fi